package com.xiaoyun.vo;

import com.xiaoyun.constant.ErrorCode;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;

@Data
@AllArgsConstructor
@NoArgsConstructor
public class Response {
    private Integer errorCode = 0;
    private String errorMsg = "";
    private Object data;

    public Response(Object data) {
        this.data = data;
    }

    public static Response failure(String feedback_error) {
        return new Response(-1, feedback_error, null);
    }

    public static Response success() {
        return new Response();
    }

    public void error(ErrorCode errorCode) {
        this.setErrorCode(errorCode.getCode());
        this.setErrorMsg(errorCode.getDesc());
    }

}
